import string
import time

from selenium import webdriver
import random
from selenium.webdriver.common.keys import Keys

from yurongtong_system_background.common.base import Base


class Add_channel_rating(Base):

    # 添加渠道等级
    channel_rating = ("xpath", "//*[@id ='user$Menu']/li[3]/span")
    add_rating = ("css selector", ".ant-btn")
    add_rating_name = (
        "xpath", "/html/body/div[2]/div/div[2]/div/div[2]/div[2]/form/div/div/div//div[2]/div/span/input")
    add_rating_submit = ("xpath", "/html/body/div[2]/div/div[2]/div/div[2]/div[3]/button[2]")

    loc_new = ("xpath",
               "// *[@id ='main-container']/div[2]/div[3]/div[1]/div[2]/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[2]")

    # 新增渠道等级
    def add_channel_rating(self, text):
        self.click(self.channel_rating)
        self.click(self.add_rating)
        self.sendKeys(self.add_rating_name, text)
        self.click(self.add_rating_submit)

    #  判断是否添加渠道等级成功
    def is_add_channel_rating_success(self, _text):
        self.driver.refresh()
        return self.is_text_in_element(self.loc_new, _text)


if __name__ == "__main__":
    pass